package com.adou.d15;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class StreamTest1 {
    public static void main(String[] args) {
        List<String> names = new ArrayList<>();
        Collections.addAll(names, "张三丰","张无忌","周芷若", "赵敏", "张强");
        System.out.println(names);
        System.out.println("==============================================");

        // 找出姓张，并且名字为3个字
        ArrayList<Object> list = new ArrayList<>();
        for (String name : names) {
            if(name.startsWith("张") && name.length() == 3) {
                list.add(name);
            }
        }

        System.out.println(list);
        System.out.println("==============================================");

        List<Object> list2 = names.stream()
                .filter(n->n.startsWith("张"))
                .filter(n->n.length() == 3)
                .collect(Collectors.toList());
        System.out.println(list2);
    }
}
